# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: damir <damir@archlinux.org>
# Contributor: Robert Emil Berge <robert@rebi.no>

pkgname=rosegarden
pkgver=22.12.1
pkgrel=2
pkgdesc="MIDI/audio sequencer and notation editor"
arch=(loong64 x86_64)
url="https://www.rosegardenmusic.com/"
license=(GPL2)
groups=(pro-audio)
depends=(
  gcc-libs
  glibc
  lirc
  hicolor-icon-theme
  qt5-base
  zlib
)
makedepends=(
  alsa-lib
  cmake
  dssi
  fftw
  jack
  ladspa
  liblrdf
  liblo
  libsamplerate
  libsndfile
  qt5-tools)
checkdepends=(
  lilypond
  python
  tex-gyre-fonts
  ttf-dejavu
  xorg-server-xvfb
)
optdepends=(
  'cups: Printing support'
  'evince: Print preview support'
  'flac: FLAC support'
  'lilypond: Notation display support'
  'mupdf: Print preview support'
  'okular: Print preview support'
  'timidity++: Softsynth support'
  'wavpack: Lossless audio codec support'
)
provides=(
  dssi-host
  ladspa-host
)
source=(
  https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.bz2
)
sha512sums=('9195c20581edeae82934d1b89095791c39850dde34547bc26f2c63dd8272715ec7b2ca63eaae2b32c8de584df4845cb72a2fc8b3d866b958584ce3aabd1fd13c')
b2sums=('76d193171dae451e9262f52679e2bad2f884d1edb48259ad9f33e573c56213124fa67194d100247a24ef363856d876096c5bfe4b3c4a2d17339d090778efccd5')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  mkdir -p test-tmp
  chmod 700 test-tmp
  export XDG_RUNTIME_DIR="$(pwd)/test-tmp"
  # disable broken lilypond_export_test: https://sourceforge.net/p/rosegarden/bugs/1640/
  # disable tests incompatible with debug symbols: https://sourceforge.net/p/rosegarden/bugs/1641/
  xvfb-run ctest --output-on-failure --test-dir build/test -E '^(lilypond_export_test|test_notationview_selection|convert)$'
}

package() {
  depends+=(
    alsa-lib libasound.so
    fftw libfftw3f.so
    jack libjack.so
    liblrdf liblrdf.so
    liblo liblo.so
    libsamplerate libsamplerate.so
    libsndfile libsndfile.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/{AUTHORS,CHANGELOG,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
# vim:set ts=2 sw=2 et:
